<template>
  <!-- 下拉框 -->
  <div style="width: 300px;">

    <h3>下拉框 - 事件绑定</h3>
    <el-select v-model="selected1" @change="selectChange" placeholder="请选择">
      <el-option value="a" label="前端"/>
      <el-option value="b" label="后端"/>
      <el-option value="c" label="服务端"/>
    </el-select>

    <h3>动态下拉框</h3>
    <el-select v-model="selected2" placeholder="请选择">
      <el-option v-for="item in data.options"
                 :value="item.value"
                 :label="item.label"
                 :key="item.value"/>
    </el-select>

  </div>
</template>

<script setup>
import {reactive, ref} from "vue";

const selected1 = ref('')
const selected2 = ref('')

const data = reactive({
  options: [
    {value: 'A', label: '前端',},
    {value: 'B', label: '后端',},
    {value: 'C', label: '服务端',}
  ]
})
//回调
const selectChange = (val) => {
  console.log("selectChange:", val)
}
</script>

<style scoped>

</style>